/**
 * @desc 函数防抖
 * @param func 函数
 * @param wait 延迟执行毫秒数
 * @param immediate true 表立即执行，false 表非立即执行
 */
export  function debounce(funcName,wait,immediate) {
    let timeout;

    return function () {
        if (timeout) clearTimeout(timeout);
        if (immediate) {
            var callNow = !timeout;
            timeout = setTimeout(() => {
                timeout = null;
            }, wait)
            if (callNow) this[funcName]()
        }
        else {
            timeout = setTimeout(() => {
                this[funcName]()
            }, wait);
        }
    }
}

